#include <stdio.h>
#include <stdlib.h>
#include <systems.h>
#include <types.h>
#include <event.h>
#include <image.h>
#include <drivers/input/input.h>
#include "unistd.h"
#include <gobjs.h>

volatile BOOLEAN machine_start = false;

extern GOBJ *btn2;

extern int GEntry(void);
extern int GExit(void);

void cleanup(int sig)
{
    GExit();


#ifdef INPUT_DEVICE_SUPPORT
    input_exit();
#endif

    graph_sys_exit();
  
    DPRINTF("Terminated!\n");
    exit(0);
}


int main(int argc, char *argv[])
{
    graph_sys_init();
    DPRINTF("Graphic system initialized!\n");
#ifdef INPUT_DEVICE_SUPPORT
    event_available(FLAG_PRESS | FLAG_RELEASE | FLAG_CLICK);
    if(input_init() < 0)
        WARNING("Input device is not ready.");
#endif
    /* Graphic entry function */
    GEntry();
    
    while(1) {
        event_arbitrator();
    }
    
    cleanup(0);
    
    return 0;
}
